package main

import (
	"fmt"
	"os"
	"os/exec"
)

func main() {
	if len(os.Args) < 2 {
		printHelp()
		os.Exit(1)
	}

	command := os.Args[1]
	switch command {
	case "list":
		handleList()
	case "checkout":
		handleCheckout(os.Args[2:])
	case "save":
		handleSave(os.Args[2:])
	case "delete":
		handleDelete(os.Args[2:])
	case "pop":
		handlePop(os.Args[2:])
	case "clean":
		handleClean()
	case "help", "-h", "--help":
		printHelp()
	default:
		fmt.Printf("未知命令: %s\n\n", command)
		printHelp()
		os.Exit(1)
	}
}

// 执行 Git 命令
func runGit(args ...string) (string, error) {
	cmd := exec.Command("git", args...)
	output, err := cmd.CombinedOutput()
	if err != nil {
		return "", fmt.Errorf("%s\n%s", err, string(output))
	}
	return string(output), nil
}
